package com.systop.service.impl;

import com.systop.mapper.GoodsPropertyMapper;
import com.systop.pojo.Goods_property;
import com.systop.service.GoodsPropertyService;
import com.systop.unti.ResponseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @Author zhangnan
 * @Data 2020/8/004 下午 3:57
 * @Descriiption
 **/
@Service
@Transactional
public class GoodsPropertyServiceImpl implements GoodsPropertyService {
    @Autowired
    private GoodsPropertyMapper goodsPropertyMapper;

    //查询所有
    @Override
    public ResponseResult selectGoodsPropertyAll() {
        List<Goods_property> goods_properties = goodsPropertyMapper.selectGoodsPropertyAll();
        if (goods_properties!=null){
            return ResponseResult.ok(goods_properties);
        }else {
            return ResponseResult.build(400, "错误");
        }
    }
    //根据id查询
    @Override
    public ResponseResult selectGoodsPropertByid(Integer goods_property_id) {
        Goods_property goods_property = goodsPropertyMapper.selectGoodsPropertByid(goods_property_id);
        if (goods_property!=null){
            return ResponseResult.ok(goods_property);
        }else {
            return ResponseResult.build(400, "错误");
        }
    }
    //根据名字查询
    @Override
    public ResponseResult selectGoodsPropertByname(String goods_property_name) {
        Goods_property goods_property = goodsPropertyMapper.selectGoodsPropertByname(goods_property_name);
        if (goods_property!=null){
            return ResponseResult.ok(goods_property);
        }else {
            return ResponseResult.build(400, "错误");
        }
    }
    //根据id删除
    @Override
    public ResponseResult deleteGoodsPropertByid(Integer goods_property_id) {
        Integer integer = goodsPropertyMapper.deleteGoodsPropertByid(goods_property_id);
        if (integer!=null){
            return ResponseResult.ok(integer);
        }else {
            return ResponseResult.build(400, "错误");
        }
    }

    //添加商品属性
    @Override
    public ResponseResult insertGoodsPropert(Goods_property goods_property) {
        Integer integer = goodsPropertyMapper.insertGoodsPropert(goods_property);
        if (integer!=null){
            return ResponseResult.ok(integer);
        }else {
            return ResponseResult.build(400, "错误");
        }
    }
    //根据id更新商品属性
    @Override
    public ResponseResult updateGoodsPropertByid(Goods_property goods_property) {
        Integer integer = goodsPropertyMapper.updateGoodsPropertByid(goods_property);
        if (integer!=null){
            return ResponseResult.ok(integer);
        }else {
            return ResponseResult.build(400, "错误");
        }
    }
}
